parasite: Don't open a window upon load
authorMatthias Clasen <mclasen@redhat.com>
Wed, 7 May 2014 02:02:08 +0000 (22:02 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 11 May 2014 02:04:18 +0000 (22:04 -0400)
Instead, we want to let GTK+ open a window whose life-cycle
it can control. We just ensure that all our types are registered
when the module is loaded, so GTK+ can find them.

modules/other/parasite/module.c
modules/other/parasite/window.c
modules/other/parasite/window.ui

index f54eadaca29c7f28db896defe1775584499fe03a..2b2db7a225adce6ce18172dfd807304b422f8d73 100644 (file)
  */
 #include <glib.h>
 
-#include "window.h"
+#include "button-path.h"
+#include "classes-list.h"
+#include "css-editor.h"
+#include "object-hierarchy.h"
+#include "property-cell-renderer.h"
+#include "prop-list.h"
 #include "python-hooks.h"
+#include "python-shell.h"
 #include "resources.h"
-
+#include "themes.h"
+#include "widget-tree.h"
+#include "window.h"
 
 void
 gtk_module_init (gint *argc, gchar ***argv)
@@ -36,7 +44,17 @@ gtk_module_init (gint *argc, gchar ***argv)
 
   parasite_register_resource ();
 
-  gtk_window_present (GTK_WINDOW (parasite_window_new ()));
+  g_type_ensure (PARASITE_TYPE_THEMES);
+  g_type_ensure (PARASITE_TYPE_CSS_EDITOR);
+  g_type_ensure (PARASITE_TYPE_BUTTON_PATH);
+  g_type_ensure (PARASITE_TYPE_WIDGET_TREE);
+  g_type_ensure (PARASITE_TYPE_PROP_LIST);
+  g_type_ensure (PARASITE_TYPE_OBJECT_HIERARCHY);
+  g_type_ensure (PARASITE_TYPE_CLASSES_LIST);
+  g_type_ensure (PARASITE_TYPE_PYTHON_SHELL);
+  g_type_ensure (PARASITE_TYPE_PROPERTY_CELL_RENDERER);
+  g_type_ensure (PARASITE_TYPE_WINDOW);
 }
 
+
 // vim: set et sw=2 ts=2:
index 9fc8646e5838ceac50979df173aaf39212514639..31242a6b96095c22fd154f84283e0f4ed9617232 100644 (file)
 
 G_DEFINE_TYPE (ParasiteWindow, parasite_window, GTK_TYPE_WINDOW)
 
-static void
-delete_window (GtkWidget *widget)
-{
-  GApplication *app = g_application_get_default ();
-
-  gtk_widget_hide (widget);
-
-  if (app)
-    g_application_quit (app);
-  else
-    exit (0);
-}
-
 extern void on_inspect (GtkWidget *button, ParasiteWindow *pw);
 
 static void
@@ -161,7 +148,6 @@ parasite_window_class_init (ParasiteWindowClass *klass)
   gtk_widget_class_bind_template_child (widget_class, ParasiteWindow, python_shell);
   gtk_widget_class_bind_template_child (widget_class, ParasiteWindow, widget_popup);
 
-  gtk_widget_class_bind_template_callback (widget_class, delete_window);
   gtk_widget_class_bind_template_callback (widget_class, on_inspect);
   gtk_widget_class_bind_template_callback (widget_class, on_graphic_updates_toggled);
   gtk_widget_class_bind_template_callback (widget_class, on_widget_tree_selection_changed);
@@ -171,16 +157,6 @@ parasite_window_class_init (ParasiteWindowClass *klass)
 GtkWidget *
 parasite_window_new (void)
 {
-  g_type_ensure (PARASITE_TYPE_THEMES);
-  g_type_ensure (PARASITE_TYPE_CSS_EDITOR);
-  g_type_ensure (PARASITE_TYPE_BUTTON_PATH);
-  g_type_ensure (PARASITE_TYPE_WIDGET_TREE);
-  g_type_ensure (PARASITE_TYPE_PROP_LIST);
-  g_type_ensure (PARASITE_TYPE_OBJECT_HIERARCHY);
-  g_type_ensure (PARASITE_TYPE_CLASSES_LIST);
-  g_type_ensure (PARASITE_TYPE_PYTHON_SHELL);
-  g_type_ensure (PARASITE_TYPE_PROPERTY_CELL_RENDERER);
-
   return GTK_WIDGET (g_object_new (PARASITE_TYPE_WINDOW, NULL));
 }
 
index 5de9238bfc3219ca09f035821281f86529f0a70b..5f71470ce6e82bb50cabb065be028a1c88be83fb 100644 (file)
@@ -23,7 +23,6 @@
   <template class="ParasiteWindow" parent="GtkWindow">
     <property name="default-height">500</property>
     <property name="default-width">1000</property>
-    <signal name="delete-event" handler="delete_window"/>
     <child type="titlebar">
       <object class="GtkHeaderBar">
         <property name="visible">True</property>